const app = getApp();
const Controller = require('../controllers/controllers.js').controller;
const util = require('../../utils/util.js');

Page({
  data: {
    banner:[{imgUrl:'https://img26.gz-lodihair.com/x/x6/home_banner_jpg.png'}],
    current: 0,
    productList: [],
    kejiList: [],
    shengtaiList:[],
    apiChannel:[],
    loading: false
  },
  onLoad() {
  let _this = this
  Controller.banner({
    "apiAdv_1": "position_alias=index_banner",
    "apiChannel_1": "ekey=1&type=tree&dir_name=hi_chanpin",
    "apiChannel_2": "ekey=2&type=tree&dir_name=hikeji",
    "apiChannel_3": "ekey=3&type=tree&dir_name=hi_shengtai",
    "channel_alias": "product"
  }).then(res => {
    console.log(res.data)
    let banner = res.data.apiAdv[1],
    productList = res.data.apiChannel[1].data[0],
    kejiList = res.data.apiChannel[2].data[0],
    shengtaiList = res.data.apiChannel[3].data[0],
    apiChannel = res.data.apiChannel

    _this.setData({
      banner,
      productList,
      kejiList,
      shengtaiList,
      apiChannel
    });
    console.log(productList)
  }).catch(res=>{

  })
    
  },
  onShow(){
 
  },
  swiper: function (e) {
    var index = e.detail.current
    this.setData({
      current: index
    })

  },
  onPageScroll: function (e) { // 获取滚动条当前位置
    
  },
  onShareAppMessage: function (e) {
    
  },
  onShareTimeline: function(res){
    
  },
  /**
   * 跳转列表页
   */
  jumpList(e) {
    util.jumpList(e)
  },
})